package com.lagou.task15;

import java.util.LinkedList;
import java.util.List;

public class WorkTest {
    public static void main(String[] args) {
        Worker w =new Worker();
        w.setName("凤姐");
        w.work();
        List lt1 = new LinkedList();
        lt1.add(0,"凤姐");
        lt1.add(1,18);
        lt1.add(2,20000);
        lt1.add(3,"欧阳峰");
        lt1.add(4,60);
        lt1.add(5,8000);
        lt1.add(6,"刘德华");
        lt1.add(7,40);
        lt1.add(8,30000);
        System.out.println(lt1);
        lt1.add(3,"张柏芝");
        lt1.add(4,35);
        lt1.add(5,3300);
        /* String  remove = (String) lt1.remove(6);
        Integer remove1 = (Integer) lt1.remove(6);
        Integer remove2 = (Integer) lt1.remove(6);
        */
        System.out.println();
        System.out.println(lt1);
        System.out.println("刘德华第一次出现的下标"+ lt1.indexOf("刘德华"));
        for(int i =9;i<lt1.size();){
            System.out.println(lt1.remove(i));
        }
        //(6)利用for 循环遍历，打印List 中所有员工的信息
        System.out.println(lt1);
        for(Object obj:lt1){
            System.out.println("取出来的元素是" + obj);
        }
        //利用迭代遍历，对List 中所有的员工调用work 方法
        w.setName("凤姐");
        w.work();
        w.setName("张柏芝");
        w.work();
        w.setName("欧阳锋");
        w.work();
        //为Worker类重写equals 方法，当姓名、年龄、工资全部相等时候才返回true
        Worker w4 = new Worker("张飞",30,300);
        Worker w5 = new Worker("张飞",35,300);
        boolean b1 = w4.equals(w5);
        System.out.println(b1);
        Worker w6 = new Worker("张飞",30,310);
         b1 = w4.equals(w6);
        System.out.println(b1);
        Worker w7 = new Worker("张飞",30,300);
        b1 = w4.equals(w7);
        System.out.println(b1);


    }
}
